package com.miracle.erp.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


// 实现类 实现所有的方法
public class HttpFilter implements Filter {

// 创建一个成员变量 filterConfig
private FilterConfig  filterConfig;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    // TODO 在这个覆写的方法中调用无参构造
    this.filterConfig  =  filterConfig;
    init();
}

public void init() throws ServletException  {

}


//---------
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
    if (request instanceof HttpServletRequest) {
        HttpServletRequest req = (HttpServletRequest) request;
        if (response instanceof HttpServletResponse) {
            HttpServletResponse resp = (HttpServletResponse) response;
            doFilter(req, resp, chain);
        }
    }
}
public void doFilter(HttpServletRequest request,
        HttpServletResponse response, FilterChain chain)
        throws IOException, ServletException {
}
@Override
public void destroy() {}

// getFilterConfig方法
//            返回值
public FilterConfig getFilterConfig(){
    return filterConfig;
}
}
